package cn.avalon.feign;

import cn.avalon.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: Avalon
 * @date: 2022年09月22日 ： 9:51
 * @version: ver1.0
 * @email 709785494@qq.com
 */
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User findById(Long id) {
                return new User(-1L, "触发熔断", "服务不可用，请稍后重试！");
            }
        };
    }
}
